﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _15.PrimeNumbers
{
    class PrimeNumbers
    {
        static void Main(string[] args)
        {
            Console.WriteLine("In what interval[0,n] you want to check");
            Console.Write("n:");
            long n = long.Parse(Console.ReadLine());
            bool[] numbers = new bool[n];
            for (int i = 2; i < n; i++)
            {
                numbers[i] = true;
            }

            
            for (int i = 2; i < Math.Sqrt(numbers.Length); i++)
            {
                if (numbers[i])
                {
                    for (long j = 2; (j * i) < n; j++)
                    {
                        numbers[j * i] = false;
                    }
                }
            }
            Console.WriteLine("Primes:");
            for (int i = 0; i < numbers.Length; i++)
            {
                if (numbers[i] == true)
                {
                    Console.WriteLine(i);
                }
            }
        }
    }
}